<template>
  <div class="my_div">
    <img :src='dogurl' alt="" />
    <h4 :style="{ backgroundColor: colorstr }" @click="btn">
      {{ name }}
    </h4>
  </div>
</template>

<script>
export default {
  props: ["dogurl", "name"],
  data() {
    return {
      colorstr: "",
    };
  },
  methods: {
    btn() {
      this.colorstr = `rgb(${Math.floor(Math.random() * 256)}, ${Math.floor(
        Math.random() * 256
      )}, ${Math.floor(Math.random() * 256)})`;
      this.$emit('love',this.name)
    },
  },
};
</script>

<style>
.my_div {
  width: 200px;
  border: 1px solid #000;
  text-align: center;
  float: left;
}
.my_div img {
  width: 100%;
  height: 200px;
}
</style>